<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		<script>
		var a=prompt("请输入考试科目数量：","score");
		if(a<=0){
			alert("输入错误")
		}
		var he=0;
		for(var i=0;i<a;i++){
			var b=parseInt(prompt("请输入第"+(i+1)+"门成绩",""));
			he=parseInt(b+he);
			if(b<0){
				alert("成绩不能是负数！")
			}
		}
		alert(i+"门成绩的总和为："+he);
	</script>

	</body>
</html>
